CONTENTS | INDEX | PREV | NEXT
FUNCTION
Easily Create Prototype File
SYNOPSIS
makeproto infile outfile
DESCRIPTION
Collects lines beginning with the word Prototype from all your source
files into a single header file. Each source module in a project
normally includes a common header file, DEFS.H, which contains items
common to the project. The idea is to add the following to your
DEFS.H file:
#define Prototype extern
#define Local static /* or as nothing at all */
#include "protos.h" /* prototype file generated by MAKEPROTO
Each source would contain prototypes that look like this (shown with
example declarations):
Prototype int FuGlob;
Prototype void FuBar(int);
Prototype struct MyFu *FuBar2(short);
int FuGlob; /* etc... */
void FuBar(int x) {
...
}
You then create a PROTOS.H file by running MAKEPROTO on all source
files. Among the tricks that are possible is the use of structure
tags instead of typedefs in the prototypes themselves, allowing the
prototype file to be #include'd during the normal course of
compilation without necessarily requiring precursor includes to
guarantee the validity of the types you use. Since a declaration
containing a pointer to an undefined structure is valid as long as
you do not try to access specific elements in the structure, this
allows you to bring in prototypes for all functions in your entire
project whether you use them in any specific source module or not.
MAKEPROTO has one additional feature which makes its usage all the
more efficient... if the specified output file already exists
MAKEPROTO will compare its output with the existing file and not
modify the date stamp of the file unless the output diffs. This is
especially useful when you use precompiled includes where you might
want to include a dependency to force the precompiled include to be
recomputed if any header file OR the prototype file changes. Without
this feature you would have to force the precompiled include to be
recomputed every time you modify a source file because you would not
be able to determine whether that modification resulted in a change
in the prototype file PROTOS.H or not.